package com.kuaimacode.kframework.admin.services.category;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kuaimacode.kframework.admin.util.SessionUtil;
import com.kuaimacode.kframework.mybatis.mapper.coupon.UserCouponMapper;
import com.kuaimacode.kframework.mybatis.models.coupon.UserCoupon;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @date 2019/03/25
 */
@Service
public class  UserCouponService extends ServiceImpl<UserCouponMapper, UserCoupon> {

    	/**
    	 *  分页查找所有的数据
    	 * @param pageNum 当前页码，从1开始
    	 * @param pageSize  一页显示多少行
    	 * @return
    	 */
    	public PageInfo<UserCoupon> findAll(int pageNum, int pageSize,UserCoupon userCoupon) {
    		PageHelper.startPage(pageNum, pageSize);
			List<UserCoupon> datas = baseMapper.queryUsersCouponList(userCoupon);
    		return new PageInfo<UserCoupon>(datas);
    	}


    	public void sendAllUser(UserCoupon userCoupon){
			userCoupon.setCreateBy(SessionUtil.getUserId());

			baseMapper.sendAllUser(userCoupon);

		}

}

